﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CalculatorLib.Interface;

namespace CalculatorLib
{
    public class BasicCalculator : IBasicCalculator
    {

        public int Add(int a, int b)
        {
            return a + b;
        }

        public int Mul(int a, int b)
        {
            return a * b;
        }

        public int Div(int a, int b)
        {
            try
            {
                return a / b;
            }
            catch (Exception)
            {
                return 0;
            }
        }

        public int Sub(int a, int b)
        {
            return a - b;
        }


        public int AddList(IEnumerable<int> listOfNumber)
        {
            int retval = 0;

            foreach (int number in listOfNumber)
            {
                retval += number;
            }

            return retval;
        }
    }
}
